[Binding/Sofa.Core] FIX Node iterators.#171
Merged
fredroy merged 2 commits intosofa-framework:masterfrom Sep 16, 2021
Merged
Conversation
So we can now write: def createScene(root): if "MyObject" in root.objects: pass if "MyChild" in root.children: pass if "MyParent" in root.parents: pass
The actually implmentation of NodeIterator is broken. Eg: - the __getitem__ by name was always returning a BaseObject whatever the iterable was on object, children or parents - the remove_at method was actually always deleting a Child whatever the iterable was on object, children or parents There is also no __contains__ operator which prevent to write pythonic if "AAA" in node.objects: pass. This PR: - fix the broken implementation on remove_at and __getitem__ by adding lambda functions allowing to implement per-type behavior. - add tests for the fixed features - implements the __contains__ method and dedicated tests. - update the corresponding docstring In this PR I also added
555d316 to
8b399b9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The actually implmentation of NodeIterator is broken.
Eg:
__getitem__by name was always returning a BaseObject whatever the iterable was on object, children or parentsThere is also no
__contains__operator which prevent to write pythonicThis PR:
__getitem__by adding lambda functions allowing to implement per-type behavior.__contains__method and dedicated tests.DRAFTED CODE FROM THE CODE-REVIEW: